#!/bin/bash
# Author: Steven Shiau <steven _at_ clonezilla org>
# License: GPL

# Load DRBL setting and functions
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"

. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
. /etc/drbl/drbl-ocs.conf
. $DRBL_SCRIPT_PATH/sbin/ocs-functions

# Load keymap if it exists
[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf

# (1) For preseed case:
# Ubuntu Saucy (13.04) does not have a mechanism like /etc/init.d/keyboard-setup (not /etc/init.d/keymap.sh) to run "setupcon -k". The keyboard-configuration package on Ubuntu saucy is 1.70ubuntu7, while that on Debian Sid (2013/11/25) is 1.103.
# Therefore here we force to run "setupcon -k" no matter in Debian or Ubuntu. This command could be run harmless. Therefore just run it without any condition.
setupcon -k

# (2) For interactive case:
# If plymouth is running, we should not run the locales and keyboard config. Will run that after entering runlevel 2
if [ -n "$(LC_ALL=C ps -efw | grep plymouth | grep -v grep)" ]; then
  # Make a tag so that later in runlevel 2 ocs-lang-kbd-conf could be run.
  touch /run/lock/start-ocs-lang-kbd-conf
  exit 2
else
  ocs-lang-kbd-conf
fi

